<?php

class ServicosController extends Site_Controller_Action
{
    public function init()
    {
        $this->body_class = 'left-sidebar';
    }

    public function indexAction()
    {
        $this->view->headLink()->prependStylesheet($this->_urlbase.'/public/media/js/jquery-ui-1.10.2.custom/css/custom-theme/jquery-ui-1.10.2.custom.css'); 
        
        $this->view->headScript()->appendFile($this->_urlbase.'/public/media/js/jquery-ui-1.10.2.custom/js/jquery-ui-1.10.2.custom.min.js');
        
        $this->view->headScript()->appendFile($this->_urlbase.'/public/media/js/conflict.js');
        
        $this->view->headLink()->prependStylesheet($this->_urlbase.'/public/media/js/bootstrap/dist/css/bootstrap-theme.min.css');
        $this->view->headLink()->prependStylesheet($this->_urlbase.'/public/media/css/bootstrap.tooltip.css');
        $this->view->headScript()->appendFile($this->_urlbase.'/public/media/js/bootstrap/dist/js/bootstrap.min.js');
        
        $this->view->headScript()->appendFile($this->_urlbase.'/public/media/js/jquery.maskedinput.min.js');
        $this->view->headScript()->appendFile($this->_urlbase.'/public/media/js/jquery.maskMoney.min.js');
        $this->view->headScript()->appendFile($this->_urlbase.'/public/media/js/mask.js');
        
        $this->view->headScript()->appendFile($this->_urlbase.'/public/media/js/validation/dist/jquery.validate.min.js');
        $this->view->headScript()->appendFile($this->_urlbase.'/public/media/js/view/agenda.js');
        
        $result = $this->db->fetchAll('SELECT SQL_CACHE b.*,c.CTS_NOM FROM ST_SERVICO b, ST_CATEGORIA_SERVICO c WHERE b.CTS_ID = c.CTS_ID AND SER_STA = 1 ORDER BY SER_NOM ASC');
        $this->view->servicos = $result; 
        
        $id = $this->_getParam('id', 0);
        if($id > 0){
            $result = $this->db->fetchRow('SELECT SQL_CACHE b.*,c.CTS_NOM FROM ST_SERVICO b, ST_CATEGORIA_SERVICO c WHERE SER_ID = '.$id.' AND b.CTS_ID = c.CTS_ID AND SER_STA = 1');
            $this->view->servico = $result; 
        } else {
            $result = $this->db->fetchRow('SELECT SQL_CACHE b.*,c.CTS_NOM FROM ST_SERVICO b, ST_CATEGORIA_SERVICO c WHERE b.CTS_ID = c.CTS_ID AND SER_STA = 1 ORDER BY SER_ID DESC');
            $this->view->servico = $result; 
        }

    }
    
    public function servicoAction()
    {
   
    }
    
}

